const song = {
    state:{
        isPlay: false,          //是否播放中
        url: '',                //歌曲地址
        id: '',
        isSunny: true,                 //歌曲id
    },
    getters: {
       isPlay: state => {
            let isPlay = state.isPlay
            if (!isPlay) {
                isPlay=JSON.parse(window.sessionStorage.getItem('isPlay')||null)
            }
            return isPlay
        },
        url: state => {
            let url = state.url
            if (!url) {
                url=JSON.parse(window.sessionStorage.getItem('url')||null)
            }
            return url
        },
        id: state => {
            let id = state.id
            if (!id) {
                id=JSON.parse(window.sessionStorage.getItem('id')||null)
            }
            return id
        },
    },
    mutations: {
       setIsPlay: (state, isPlay) => {
            state.isPlay = isPlay
            window.sessionStorage.setItem('isPlay',JSON.stringify(isPlay))
        },
        setUrl: (state, url) => {
            state.url = url
            window.sessionStorage.setItem('url',JSON.stringify(url))
        },
        setId: (state, id) => {
            state.id = id
            window.sessionStorage.setItem('id',JSON.stringify(id))
        },
    }
}

export default song